function showInformRuleSearch(){
	window.location.href="showInformRuleSearch.do";
}

function ajaxFindInformRuleSearchList(currentPage,pageSize) {
	$.ajax({
		type:"post",
		url: "ajaxInformRuleSearchList.do",
		data:{
			groupname:$("#txtIFRroupName").val(),
			currentPage:currentPage,
			pageSize:pageSize,
			orderBy:"id",
		},
		success:function(msg){
			$("#listInformRuleBox").html(msg);
		}
	});
}

function ajaxShowInformRuleEdit(id){
	$.ajax({
		type:"post",
		url:"ajaxShowInformRuleEdit.do",
		data:{informRuleId:id},
		success:function(msg){
			$("#dialog2").html(msg);
			$("#dialog2").dialog({
				autoOpen: true,
				width: 650,
				title:$(".dialogtitle").attr("title"),
				modal: true,
				buttons : [{
					text : "保存",
					click : function() {
						ajaxSaveInformRule(this);
					}
				}, {
					text : "关闭",
					click : function() {
						$(this).dialog("close");
					}
				}]
			});
		}
	});
}

function ajaxSaveInformRule(objDialog) {
	informRuleValidate();
	if ($("#frmInformRule").valid()) {
		$(objDialog).dialog("close");
		var options ={
				type: "post",
				url : "ajaxSaveInformRule.do",
				success: function () {
					clearInput("#sltInformRule");
					ajaxFindInformRuleSearchList(1);
					showMessageDialog("保存告知规则","告知规则信息保存成功。",null,dialogType.info);
				}
		};
		var i = 0;
		$("#vehicleDialog tbody input[type='hidden']").each(
				function () {$(this).attr("name","illegalVehicleInfoList["+ i++ +"].id");}
		);
		$("#frmInformRule").ajaxSubmit(options);
	}
}

function ajaxShowInformRuleView(id){
	$.ajax({
		type:"post",
		url:"ajaxShowInformRuleView.do",
		data:{id:id},
		success:function(msg){
			$("#dialog").html(msg);
			$("#dialog").dialog({
				autoOpen: true,
				width: 500,
				title:$(".dialogtitle").attr("title"),
				modal: true,
				buttons : [ {
					text : "关闭",
					click : function() {
						$(this).dialog("close");
					}
				} ]
			});
		}
	});
}

function ajaxDeleteInformRuleById(id) {
	var informRuleIds="";
	var sltIFR = $("#listInformRuleList tbody input:checked").length;
	if(id==null){
		$("#listInformRuleList tbody input:checked").each(function(){ 
			informRuleIds += $(this).val()+";";
		});
		if (informRuleIds == ""){
			showMessageDialog("提示","请选择一行或多行",null,dialogType.info);
			return;
		}else{
			informRuleIds=informRuleIds.substring(0, informRuleIds.length-1);
		}
	}else{
		informRuleIds=id;
		sltIFR = 1;
	}
	if (informRuleIds!=null) {
		showMessageDialog("删除告知规则","确定要删除所选“"+sltIFR+"”条告知规则记录吗？",
				function () {
			$.ajax({					
				type:"post",
				url:"ajaxDeleteInformRuleByIds.do",
				data:{informRuleIds:informRuleIds},
				success:function(msg){
					ajaxFindInformRuleSearchList();
					showMessageDialog("提示","告知规则删除成功",null,dialogType.info);
				}
			});}
		,dialogType.warning);
	} 
}

function informAccountDialogView(){
	$("#informAccountDialogView").dialog({
		autoOpen: true,
		width: 650,
		modal: true,
		buttons : [ {
			text : "关闭",
			click : function() {
				$(this).dialog("close");
			}
		} ]
	});
}

function informObjectDialogView(){
	$("#informObjectDialogView").dialog({
		autoOpen: true,
		width: 650,
		modal: true,
		buttons : [ {
			text : "关闭",
			click : function() {
				$(this).dialog("close");
			}
		} ]
	});
}

function informTemplateDialogView(){
	$("#informTemplateDialogView").dialog({
		autoOpen: true,
		width: 650,
		modal: true,
		buttons : [ {
			text : "关闭",
			click : function() {
				$(this).dialog("close");
			}
		} ]
	});
}

function getDialogRightForString(rightId,hiddenInputId) {
	var value="";
	var tmp="";
	$('#'+rightId+' tbody tr').each(function(){
		tmp = $(this).attr('id');
		value+=tmp.substring(6, tmp.length)+",";
	});
	value=value.substring(0,value.length-1);
	$("#" +hiddenInputId).val(value);
}
